import axios from 'axios'

export const getsongUrl = id => {
   return axios.get(`song/url?id=${id}`)
}

export const getSongDetail = id => {
   return axios.get(`/song/detail?ids=${id}`)
}
// 初始化歌曲格式
export const initialSong = song => {
   var singer = _singer(song.ar);
   function _singer(array) {
      var data = array.map(element => {
          return element.name;
      });
      return data.join("/");
   }
   
   return {
      id: song.id,
      name: song.name,
      singer: singer,
      picUrl: song.al.picUrl,
      album: song.al.name,
      time: song.dt/1000,
      url: `https://music.163.com/song/media/outer/url?id=${song.id}.mp3`
   }
}